//简单类定义
class Dog{
    name: string;
    constructor(name: string) {
        this.name = name;
    }
    eat(food: string):void{
        console.log(this.name + '吃' + food)
        const that = this
        setTimeout(function(){
            console.log(that.name + '吃' + food)
        }, 1000);
        // 注意第二个setTimeout用箭头函数方式 是可以识别 this 的 注意区别
        setTimeout(()=>{
            console.log(this.name + '吃' + food)
        },2000);
    }
}

let a = new Dog('旺旺');

a.eat('骨头');



